<?php
namespace App\Models;


use DB;
use Illuminate\Database\Eloquent\Model;

class CommentFavourM extends Model
{
    static public $STable="lee_comment_favour";
    protected $table="lee_comment_favour";
    
    /**
     * 根据comment的id和 userid,添加数据记录
     * @param bigint $cmtid,comment的id
     * @param bigint $userid,user的id
     */
    static public function addItem($cmtid,$userid){
            $cmtFInst=new CommentFavourM();
            $cmtFInst->commentid=$cmtid;
            $cmtFInst->userid=$userid;
            $cmtFInst->save();  
    }
    
    /**
     * 根据comment的id和 userid,删除数据记录
     * @param bigint $cmtid,comment的id
     * @param bigint $userid,user的id
     */
    static public function deltItem($cmtid,$userid){
        $cond=["commentid"=>$cmtid,'userid'=>$userid];
        self::where($cond)->delete();
    }
    
    /**
     * 根据 comment的id 删除数据记录
     * @param bigint $cmtid,comment的id
     */
    static public function deltCmtFavourByID($cmtid){
        CommentFavourM::where('commentid','=',$cmtid)->delete();
    }
    
    /**
     * 依据 comment 的id集合 删除相应的数据记录
     * @param array $cmtids，comment's ids
     * 二维数组 [cmtid1,cmtid2,cmtid3]
     */
    static public function deltItemsByCmtIDs(array $cmtIds){
        self::whereIn('commentid',$cmtIds)->delete();
    }
    
}
?>